<?php

require_once dirname(__FILE__).'/../bootstrap/unit.php';
 
$t = new lime_test(7);
 
$t->comment('1 - ::cleanUsername()');

$t->is( Toolbase::cleanUsername( '  Foo  ' ), 'Foo', 'Username is trimmed' );
$t->is( Toolbase::cleanUsername( 'Fo&#39;o' ), 'Fo\'o', 'Apostrophes are parsed' );
$t->is( Toolbase::cleanUsername( 'Fo%20o' ), 'Fo o', 'Spaces are replaced' );
$t->is( Toolbase::cleanUsername( 'Foo%29' ), 'Foo)', 'Urldecoded' );
$t->is( Toolbase::cleanUsername( 'F_oo' ), 'F oo', 'Underscores are replaced' );
$t->is( Toolbase::cleanUsername( 'foo' ), 'Foo', 'Username is uppercased' );



$t->comment('2 - ::getPossibleLanguages()');

sfConfig::set( 'sf_app_i18n_dir_old', sfConfig::get( 'sf_app_i18n_dir' ) );

$tmp_dir = sys_get_temp_dir();
mkdir( $tmp_dir . '/toolbase_test' );
$tmp_dir = $tmp_dir . '/toolbase_test';
mkdir( $tmp_dir . '/de' );

sfConfig::set( 'sf_app_i18n_dir', $tmp_dir );

$t->is( Toolbase::getPossibleLanguages(), array( 'de', 'en' ) );

sfConfig::set( 'sf_app_i18n_dir', sfConfig::get( 'sf_app_i18n_dir_old' ) );

rmdir( $tmp_dir . '/de' );
rmdir( $tmp_dir );
